package day01;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;

public class Client {
    Socket socket;

    public Client(){
        // socket = new Socket();
        try {
            System.out.println("連接中");
            socket = new Socket("localhost", 8088);
            System.out.println("已連接");
        }catch (IOException e){
            e.printStackTrace();
        }
    }

    public void start(){
        try {
            OutputStream output = socket.getOutputStream();
            String message = "客戶端:服務器你好";
            output.write(message.getBytes("utf8"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void main(String[] args) {
       Client client = new Client();
        client.start();
    }
}
